/**  
 * @Title:  patPractice0027.java   
 * @Package com.wkr.pat.basiclevel   
 * @Description:    TODO(用一句话描述该文件做什么)   
 * @author: WuKangrong     
 * @date:   2018年7月24日 下午4:54:40   
 * @version V
 * @JDKversion:1.8.0
 * @Copyright: 2018  
*/
package com.wkr.pat.basiclevel;
import java.util.*;
/**   
 * @ClassName:  patPractice0027   
 * @Description:TODO(打印沙漏)   
 * @author: WuKangrong 
 * @date:   2018年7月24日 下午4:54:40     
 * @Copyright: 2018 
 */
public class patPractice0027 {
	
	/**
	 * @param topOfSymbolCount 沙漏顶部符号数
	 * @param allOfSymbolCount 沙漏总符号数
	 * @param in_Number 输入的数值
	 */
	static int topOfSymbolCount = 1;
	static int allOfSymbolCount = 1;
	static String in_String;
	static int in_Number;
	static String symbol;
	
	/**   
	 * @Title: main   
	 * @Description: TODO(这里用一句话描述这个方法的作用)   
	 * @param: @param args      
	 * @return: void      
	 * @throws   
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		inputOfInteraction();
		getTopOfSymbolCount();
		printHourglass();
		System.out.println("运行结束！");

	}
	
	/**   
	 * @Title: inputOfInteraction   
	 * @Description: TODO(输入交互)   
	 * @param:       
	 * @return: void      
	 * @throws   
	 */
	static void inputOfInteraction()
	{
		Scanner sc = new Scanner(System.in);
		in_String = sc.nextLine();
		String[] temp_StringArray = in_String.split(" ");
		in_Number = Integer.valueOf(temp_StringArray[0]);
		symbol = temp_StringArray[1];
		if(in_Number < 7) {
			System.out.println("无法正确输出沙漏，程序已终止！");
			System.exit(0);
		}
	}
	
	/**   
	 * @Title: getTopOfSymbolCount   
	 * @Description: TODO(计算在数值范围内最大沙漏的顶部符号数)   
	 * @param:       
	 * @return: void      
	 * @throws   
	 */
	static void getTopOfSymbolCount()
	{ 
		while (true) {
			topOfSymbolCount += 2;
			allOfSymbolCount = allOfSymbolCount + 2 * topOfSymbolCount;
			if (allOfSymbolCount > in_Number) {
				break;
			}
		}
		topOfSymbolCount -= 2;
	}
	
	/**   
	 * @Title: calculateSymbolCount   
	 * @Description: TODO(打印沙漏)   
	 * @param:       
	 * @return: void      
	 * @throws   
	 */
	static void printHourglass()
	{
		printAdverseTriangle();
		printNoRegularTringle();
	}
	
	/**   
	 * @Title: printAdverseTriangle   
	 * @Description: TODO(打印倒上三角)   
	 * @param:       
	 * @return: void      
	 * @throws   
	 */
	static void printAdverseTriangle()
	{
		int temp_TopOfSymbolCount = topOfSymbolCount;//存放顶部符号数量
		int lineNum = 0;//行数
		while(true) {
			for (int flag = 0; flag < lineNum; flag++) {
				System.out.print(" ");
			}
			for (int flag = 0; flag < temp_TopOfSymbolCount; flag++) {
				System.out.print(symbol);
			}
			System.out.println();
			temp_TopOfSymbolCount -= 2;
			if (temp_TopOfSymbolCount < 0) {
				break;
			}
			lineNum++;
		}
	}
	
	/**   
	 * @Title: printNoRegularTringle   
	 * @Description: TODO(打印下三角)   
	 * @param:       
	 * @return: void      
	 * @throws   
	 */
	static void printNoRegularTringle()
	{
		int lineNum = 1;//行数
		int baseOfSymbolCount = 3;//存放底层符号数量
		while (true) {
			for(int flag = (topOfSymbolCount - 1) / 2; flag > lineNum;  flag--) {
				System.out.print(" ");
			}
			for (int flag = 0; flag < baseOfSymbolCount; flag++) {
				System.out.print(symbol);
			}
			System.out.println();
			baseOfSymbolCount += 2;
			if (baseOfSymbolCount > topOfSymbolCount) {
				break;
			}
			lineNum++;
		}
	}

}
